<script type="text/javascript">
    function showFields(valor){
        if (valor == 3 || valor == 2) {
            document.getElementById('divout').style.display='none';
        }else{
            document.getElementById('divout').style.display='block';
        }
    }
	function showFields(valor){
        if (valor == 0) {
            document.getElementById('divout2').style.display='none';
        }else{
            document.getElementById('divout2').style.display='block';
        }
    }
	function showFields_dominio_completo(valor){
        if (valor == 2 || valor == 3) {
            document.getElementById('dominio_completo').style.display='none';
        }else{
            document.getElementById('dominio_completo').style.display='block';
        }
    }
	function showFields_motor_completo(valor){
        if (valor == 2 || valor == 3) {
            document.getElementById('motor_completo').style.display='none';
        }else{
            document.getElementById('motor_completo').style.display='block';
        }
    }
	function showFields_chasis_completo(valor){
        if (valor == 2 || valor == 3) {
            document.getElementById('chasis_completo').style.display='none';
        }else{
            document.getElementById('chasis_completo').style.display='block';
        }
    }
    function sendForm2(){
		if(jQuery("#MasterFechaDay").val()==""){
                    jQuery("#MasterFechaDay").addClass("reqdate");window.scroll(2,2);
                    return false;
                   }
		if(jQuery("#MasterFechaMonth").val()==""){
                    jQuery("#MasterFechaMonth").addClass("reqdate");window.scroll(2,2);
                    return false;
                   }
		if(jQuery("#MasterFechaYear").val()==""){
                    jQuery("#MasterFechaYear").addClass("reqdate");window.scroll(2,2);
                    return false;
                   }
		if(jQuery("#VehiclesDominio").val()=="" && (jQuery("#VehiclesDomParcial").val()=="0" || jQuery("#VehiclesDomParcial").val()=="1")){
                    jQuery("#VehiclesDominio").addClass("reqinput");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#VehiclesVehiclesTypesId").val()==""){
                  //  jQuery(".required").removeClass("inputsize2");
                    jQuery("#VehiclesVehiclesTypesId").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
                   }
		if(jQuery("#brands").val()==""){
                    jQuery("#brands").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#models").val()==""){
                    jQuery("#models").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#VehiclesNroMotor").val()=="" && jQuery(("#VehiclesMotorParc").val()=="0" || jQuery("#VehiclesMotorParc").val()=="1")){
                    jQuery("#VehiclesNroMotor").addClass("reqinput");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#VehiclesNroChasis").val()=="" && (jQuery("#VehiclesChasisParc").val()=="0" || jQuery("#VehiclesChasisParc").val()=="1")){
                    jQuery("#VehiclesNroChasis").addClass("reqinput");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#jurisdictions").val()==""){
                    jQuery("#jurisdictions").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#provinces").val()==""){
                    jQuery("#provinces").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#charters").val()==""){
                    jQuery("#charters").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#placements").val()==""){
                    jQuery("#placements").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#courts").val()==""){
                    jQuery("#courts").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#secretaries").val()==""){
                    jQuery("#secretaries").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#CausesPoliceStationsId").val()==""){
                    jQuery("#CausesPoliceStationsId").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#CausesNroCausa").val()==""){
                    jQuery("#CausesNroCausa").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#MasterCarpeta").val()==""){
                    jQuery("#MasterCarpeta").addClass("reqinput2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#MasterAuditoria").val()==""){
                    jQuery("#MasterAuditoria").addClass("reqinput");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#MasterPericia").val()==""){
                    jQuery("#MasterPericia").addClass("reqinput2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#VehiclesRodamiento").val()==""&& jQuery("#MasterPericia").val()=="1"){
                    jQuery("#VehiclesRodamiento").addClass("reqinput");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#MasterCajaArchivo").val()==""){
                    jQuery("#MasterCajaArchivo").addClass("reqinput");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#MasterStatesId").val()==""){
                    jQuery("#MasterStatesId").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
                   }
		if(jQuery("#MasterDespositsId").val()==""){
                    jQuery("#MasterDespositsId").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
                   }		

      	}
</script>
<div class="masters form">
<?php $this->Html->script('prototype', array('inline' => false));?>
<?php echo $this->Form->create('Master',array('type'=>'file'));?>
	<h4 style="margin-top: 0px; margin-bottom: 8px;"><legend><?php __('Add Master'); ?></legend></h4>
	<fieldset>
		<div style=" margin-left:0px; width: 1000px; ">
		<div>
		<div style="padding-left:10px; padding-top:1px; width: 500px; float:left;">
		
            <fieldset>
            <h5 style="margin-top: 0px; margin-bottom: 8px;"><legend><?php __('Vehiculo'); ?></legend></h5>
			
				<span><?php 
				
				//echo $this->Form->input('fecha',array('dateFormat' => 'DMY', 'empty' =>'-', 'label'=>'Fecha de Secuestro', 'tabindex' =>'1'));
				
				echo $this->Form->input('fecha',array('dateFormat' => 'DMY', 'empty' =>'-', 'label'=>'Fecha de Secuestro', 'tabindex' =>'1', 'maxYear' => (date('Y') - 0) ));
				

				
				?></span>
		        <span style="float: left;"><?php echo $this->Form->input('Vehicles.vehicles_types_id',array('label'=> 'Tipo de Vehículo','options'=>$vehicles_type,'type'=>'select','empty'=>'--Seleccione--','class' => 'inputsize2', 'tabindex' =>'2'));?></span>
				<span><?php echo $this->Form->input('Models.brands_id' , array('label'=> 'Marca','empty' => '-- Seleccione --','id'=>'brands','class' => 'inputsize2', 'tabindex' =>'3'));?></span>
				<span><?php echo $this->Form->input('Vehicles.models_id' , array('label'=> 'Modelo','empty' => '-- Seleccione --','id'=>'models','class' => 'inputsize2', 'tabindex' =>'4'));?></span>
				<br/>
				<span style="float: left;"><?php echo $this->Form->input('Vehicles.extranjero' , array('label'=>'Dominio Extranjero','empty'=>array('0'=>'No','1'=>'Si'),'type'=>'select','selected'=>'0','class' => 'inputsize4', 'tabindex' =>'5'));?></span>
				<span><?php echo $this->Form->input('Vehicles.dom_parcial' ,array('label'=>'N° Dominio Completo','empty'=>array('0'=>'No','1'=>'Si','2'=>'Ilegible','3'=>'No Posee'),'type'=>'select','selected'=>'1','class' => 'inputsize4', 'tabindex' =>'6', 'onChange' => 'showFields_dominio_completo(this.value)' )); ?></span>
				<div id="dominio_completo">
				<span><?php echo $this->Form->input('Vehicles.dominio' ,array('label'=>'Dominio', 'tabindex' =>'7'));?></span>
				</div>
				<span style="float: left;"><?php  echo $this->Form->input('Vehicles.motor_parc' ,array('label'=>'N° Motor Completo','empty'=>array('0'=>'No','1'=>'Si','2'=>'Ilegible','3'=>'No Posee'),'type'=>'select','selected'=>'1','class' => 'inputsize4', 'tabindex' =>'8', 'onChange' => 'showFields_motor_completo(this.value)'));?></span>
				<span><?php  echo $this->Form->input('Vehicles.chasis_parc', array('label'=>'N° Chasis Completo','empty'=>array('0'=>'No','1'=>'Si','2'=>'Ilegible','3'=>'No Posee'),'type'=>'select','selected'=>'1','class' => 'inputsize4', 'tabindex' =>'9', 'onChange' => 'showFields_chasis_completo(this.value)'));?></span>
				<div id="motor_completo">
				<span><?php  echo $this->Form->input('Vehicles.nro_motor' ,array('label'=>'N° Motor', 'tabindex' =>'10'));?></span>
				</div>
				<div id="chasis_completo">
				<span><?php  echo $this->Form->input('Vehicles.nro_chasis' ,array('label'=>'N° de Chasis', 'tabindex' =>'11'));?></span>
				</div>
			 </fieldset>
		</div>
		
	    <div style="padding-left:10px; padding-top:1px; width: 450px; float:left;">
        <fieldset>    
                <h5 style="margin-top: 0px; margin-bottom: 8px;"><legend><?php __('Legajo'); ?></legend></h5>
				<span><?php echo $this->Form->input('fecha_compactacion',array('dateFormat' => 'DMY','label'=>'Fecha de Compactación','empty'=>'-', 'tabindex' =>'21', 'maxYear' => (date('Y') - 0)));?></span>
				<br/>
				<span style="float: left;"><?php echo $this->Form->input('Master.carpeta', array('options'=>array('0'=>'No','1'=>'Si'),'label'=> 'Carpeta', 'type'=>'select','empty'=>'--', 'tabindex' =>'22'));?></span>
				<span><?php echo $this->Form->input('Master.auditoria',array('options'=>array('0'=>'No','1'=>'Si'),'label'=>'Acta de Auditoría','type'=>'select','empty'=>'--', 'tabindex' =>'23'));?></span>
				<span style="float: left;"><?php echo $this->Form->input('Master.pericia',array('options'=>array('0'=>'No','1'=>'Si'),'label'=>'Pericia','type'=>'select','empty'=>'--', 'tabindex' =>'24', 'onChange' => 'showFields2(this.value)'));?></span>
				<div id="divout2">
				<span><?php  echo $this->Form->input('Vehicles.rodamiento', array('label'=>'Rodamiento','options'=>array('0'=>'No Apto','1'=>'Apto'),'type'=>'select','empty'=>'--','class' => 'inputsize3', 'tabindex' =>'25'));    ?></span>
				</div>
				<span><?php echo $this->Form->input('Master.foto',array('options'=>array('0'=>'No','1'=>'Si'),'type'=>'select','empty'=>'--', 'tabindex' =>'26'));?></span>
				<br/>
				<span style="float: left;"><?php echo $this->Form->input('Master.nro_expediente',array('label'=>'N° de Expte. Ministerial', 'tabindex' =>'27'));?></span>
				<span style="float: left;"><?php echo $this->Form->input('Master.nro_resolucion',array('label'=>'N° de Resolución de Compactación', 'tabindex' =>'28'));?></span>
				<span><?php echo $this->Form->input('Master.caja_archivo', array('label'=>'Caja de Archivo', 'tabindex' =>'29'));?></span>
			
        </fieldset>   
	    </div>
		  
		<div style="clear:both;"> 
	
	    <div style="clear:both;">
	    <div style="padding-left:10px; padding-top:1px; width: 500px; float:left;">
            <fieldset>
            <h5 style="margin-top: 0px; margin-bottom: 8px;"><legend><?php __('Datos Judiciales'); ?></legend></h5>
			
		    <span style="padding-left: 60px;">
            <?php echo $this->Form->input('jurisdictions_id',array('id'=>'jurisdictions','empty' => '-- Seleccione --', 'label'=> 'Jurisdicción','class' => 'inputsize', 'tabindex' =>'12'));?>
           
			<?php echo $this->Form->input('provinces_id',array('label'=>'Provincia','id'=>'provinces','empty' => '-- Seleccione --','class' => 'inputsize', 'tabindex' =>'13'));?>
                 
			 
			 <?php echo $this->Form->input('charters_id',array('id'=>'charters','empty' => '-- Seleccione --', 'label'=> 'Fuero', 'tabindex' =>'14')); ?>
			 <?php echo $this->Form->input('placements_id',array('id'=>'placements','empty' => '-- Seleccione --', 'label'=> 'Depto. Judicial o Circunscripción','class' => 'inputsize', 'tabindex' =>'15'));?>
			 <br/>
			 <?php echo $this->Form->input('courts_id',array('id'=>'courts','empty' => '-- Seleccione --', 'label'=> 'Juzgado','class' => 'inputsize', 'tabindex' =>'16'));?>
             <?php echo $this->Form->input('Causes.secretaries_id',array('id'=>'secretaries','empty' => '-- Seleccione --', 'label'=> 'Secretaría','class' => 'inputsize', 'tabindex' =>'17'));?>
             <?php echo $this->Form->input('Causes.police_stations_id',array('empty'=>'--Seleccione--','options'=>$police_stations,'type'=>'select','class' => 'inputsize', 'tabindex' =>'18'));?>
             <?php echo $this->Form->input('Causes.nro_causa', array('label'=>'Nº de Causa', 'tabindex' =>'19'));?>
             <?php echo $this->Form->input('Causes.descripcion', array('label'=>'Descripción', 'tabindex' =>'20'));?>
			</span>
            </fieldset>
	    </div>
		
	    <div style="width: 450px; padding-top:1px; float:left; padding-left: 10px;">
            <fieldset>    
            <h5 style="margin-top: 0px; margin-bottom: 8px;"><legend><?php __('Ubicación y Estado'); ?></legend></h5>
		    <span style="padding-left: 60px;">
            <?php echo $this->Form->input('states_id',array('label'=>'Estado','type'=>'select','options'=>$states,'empty'=>'--Seleccione--','class' => 'inputsize2', 'tabindex' =>'30'));?>
		    <div id="divout">
			<?php echo $this->Form->input('desposits_id',array('label'=>'Depósito','options'=>$desposits,'type'=>'select','empty'=>'--Seleccione--','class' => 'inputsize2', 'tabindex' =>'31'));?>
		    </div>
			<?php echo $this->Form->input('observaciones',array('tabindex' =>'32'));?>
		    
		    </span>
            </fieldset>
		</div>
		
		<div style="width: 450px; padding-top:1px; float:left; padding-left: 10px;">
            <fieldset>    
            <h5 style="margin-top: 0px; margin-bottom: 8px;"><legend><?php __('Fotos'); ?></legend></h5>
		    <span style="padding-left: 60px;">
            <?php echo $form->input('file', array('type'=>'file','label'=>'Foto','tabindex' =>'33')); ?>
			</span>
            </fieldset>
		</div>
		
		
		  
        <div style="clear:both;">	   
	   <?php echo $form->submit('Guardar', array('onClick' => 'sendForm().returnValue = false; return false;')); ?>
	   
	    <?php echo $this->Form->end();
        $options1 = array('url' => 'update_select', 'update' => 'models');
        echo $ajax->observeField('brands', $options1);

        $options2 = array('url' => 'update_jurisdictions', 'update' => 'provinces');
        echo $ajax->observeField('jurisdictions', $options2);

        $options3 = array('url' => 'update_provinces', 'update' => 'charters');
        echo $ajax->observeField('provinces',$options3);
    
        $options4 = array('url' => 'update_placements', 'update' => 'placements');
        echo $ajax->observeField('charters',$options4);
    
        $options5 = array('url' => 'update_courts', 'update' => 'courts');
        echo $ajax->observeField('placements',$options5);
    
        $options6 = array('url' => 'update_secretaries', 'update' => 'secretaries');
        echo $ajax->observeField('courts',$options6);
        ?>
        </div> 